<?php
class UserModel extends Model{
	public function addUser(){
		$user = new User();
		$user->setEmail($this->params['email']);
        $user->setName($this->params['name']);
        $user->setPassword($this->params['password']);
        $user->setEmail($this->params['email']);
     	$user->setSerName($this->params['sername']);
		$user->setFoto($this->params['foto']);
		$user->setSex($this->params['sex']);
		$user->setAge($this->params['age']);
		$user->setMessage($this->params['message']);
        
		UserMapper::seve($user);
		
	}
	
	public function auth(){//Login
		var_dump($this->params);
		if(isset($this->params['email']) && isset($this->params['password'])){
			$userId = UserMapper::auth($this->params['email'], $this->params['password']);
			if($userId){
				$_SESSION['user_id'] = $userId;
        	}
        }else{
        	$this->view->setErrorString('Неправильный логин или email');
        }
		
		
		
	}
	public function logout(){
		session_destroy();
	}
	
}
?>